<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="姓名" v-model="name">
  <input type="text" placeholder="工资" v-model="salary">
  <input type="text" placeholder="工作" v-model="job">
  <input type="button" value="添加" @click="f()">
  <table border="1">
    <caption>员工列表</caption>
    <tr>
      <th>姓名</th>
      <th>工资</th>
      <th>工作</th>
    </tr>
    <tr v-for="emp in arr">
      <td>{{emp.name}}</td>
      <td>{{emp.salary}}</td>
      <td>{{emp.job}}</td>
    </tr>
  </table>
</div>
<!--引入vue框架文件-->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      arr:[{name:"刘备",salary:5000,job:"销售"},
        {name:"关羽",salary:3000,job:"人事"},
        {name:"张飞",salary:1000,job:"财务"}],
      name:"",
      salary:"",
      job:""
    },
    methods:{
      f(){
        //创建一个新员工对象把用户输入的信息封装进去
        let emp = {name:v.name,salary:v.salary,job:v.job};
        //把创建的员工对象添加到数组中
        v.arr.push(emp);
      }
    }
  })
</script>
</body>
</html>